﻿Imports System.Data.OleDb

Public Class Register
    Inherits System.Web.UI.Page

    Dim tb_modSpecial As Object
    Dim tb_mod As Object

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        RegisterUser.ContinueDestinationPageUrl = Request.QueryString("ReturnUrl")
    End Sub

    Protected Sub RegisterUser_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles RegisterUser.CreatedUser
        FormsAuthentication.SetAuthCookie(RegisterUser.UserName, False)

        Dim conn As New OleDbConnection(ConfigurationManager.ConnectionStrings("MotorcyclesConn").ConnectionString)

        Dim sql As String = "INSERT INTO UserAccounts (Username) VALUES (@f1)"

        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)

        conn.Open()

        cmd.Parameters.AddWithValue("@f1", RegisterUser.UserName)

        cmd.ExecuteNonQuery()

        Dim continueUrl As String = RegisterUser.ContinueDestinationPageUrl
        If String.IsNullOrEmpty(continueUrl) Then
            continueUrl = "~/"
        End If

        Response.Redirect(continueUrl)
    End Sub
End Class